<?php 
/**
*小区经理
*/
require("./include/init.php");
//目前发现也只有一个区域经理,而且正在线上的网站,此功能貌似并未使用
//因为只有一个总经理,下属而且只有一家店,因此,直接查询出此店的数据即可
$mysql=mysql::getIns();
date_default_timezone_set('Asia/Shanghai');
@$address=$_REQUEST['address'];
if(empty($address)){
	$address="北京博瑞祥星汽车销售有限公司";
}

if($address=='北京博瑞祥星汽车销售有限公司'){
	$title='北部区';
}else if($address=="义乌市博奥汽车销售服务有限公司"){
	$title='浙江区';
}else if($address=='广州粤奥汽车销售服务有限公司'){
	$title='南部区';
}else if($address=='辽宁鑫迪汽车销售服务有限公司'){
	$title='东北区';
}else if($address=='江苏天奥汽车销售服务有限公司'){
	$title='东部区';
}else if($address=='成都新元素雅麓汽车销售服务有限公司'){
	$title='西部区';
}else if($address=='云南驰泰汽车销售服务有限公司'){
	$title='西部区';
}else if($address=='宁夏奥立升汽车销售服务有限公司'){
	$title='西部区';
}else if($address=="陕西奥诚汽车销售服务有限公司"){
	$title='西部区';
}
$maxtime=time();
$mintime=$maxtime-10*60;
// echo $maxtime . '<br />';
// echo $mintime;
$sql="select count(*) from alldev where timestamp > $mintime and timestamp < $maxtime and shop='". $address ."'";
$allnow=$mysql->getOne($sql);
// echo $allnow;
// print_r($allnow);
// exit;


//统计当天累计人数数
$t = time();
$start = mktime(0,0,0,date("m",$t),date("d",$t),date("Y",$t));
$end = mktime(23,59,59,date("m",$t),date("d",$t),date("Y",$t));
$sql="select count(*) from alldev where timestamp > $start and timestamp < $end and shop='" . $address . "'";
$allday=$mysql->getOne($sql);

//首次今天首次进店人数,通过字段visittimes为1来进行判断
$sql="select count(*) from alldev where visittimes=1 and timestamp > $mintime and timestamp < $maxtime and shop='".$address ."'";
$first=$mysql->getOne($sql);

//统计当前销售区
$sql="select count(*) from alldev where timestamp > $mintime and timestamp < $maxtime and shop='" . $address ."' and area in ('展厅区','销售区','精品区')";
$sale=$mysql->getOne($sql);
// echo $sale;
// print_r($sale);
// exit;

//统计当前售后区
$service=$allnow-$sale;


//今天多次进店人数
$sql="select count(*) from alldev where visittimes <> 1 and timestamp > $mintime and timestamp < $maxtime and shop='" . $address ."'";
$second=$mysql->getOne($sql);

//统计登陆人数
$sql="select count(*) from alldev where isOL=1 and timestamp > $mintime and timestamp < $maxtime and shop='" . $address ."'";
$login=$mysql->getOne($sql);
// echo $login;

//统计未登陆人数
$sql="select count(*) from alldev where isOL=2 and timestamp > $mintime and timestamp < $maxtime and shop='" . $address ."'";
$nolog=$mysql->getOne($sql);

//统计历史进店人数
$sql="select count(*) from alldev where shop='". $address ."'";
$history=$mysql->getOne($sql);
$data=include('./include/history.inc.php');
// print_r($data);
$b=$data["$address"];
$history+=$b;

require(ROOT . 'view/iwocar5/SubArea_Main.html');
 ?>
